package modularity.passiveDrift;

import java.util.ArrayList;

public class BasicGenomeFactory implements GenomeFactory<BasicGenome>{

	public ListedPopulation generateInitialPopulation(int populationSize, int inputNodes, int outputNodes){
		ListedPopulation pop = new ListedPopulation(populationSize);
		
		ArrayList<Integer> inputs = new ArrayList<Integer>(inputNodes);
		for(int i = 1; i <= inputNodes; i++)
			inputs.add(i);
		
		ArrayList<Integer> outputs = new ArrayList<Integer>(outputNodes);
		for(int i = inputNodes + 1; i <= inputNodes + outputNodes; i++)
			outputs.add(i);
		
		for(int i = 0; i < populationSize; i++){
			BasicGenome genome = generateGenome(inputs, outputs);
			setName(genome, String.valueOf(i+1));
			pop.add(genome);
		}
		return pop;
	}
	
	public BasicGenome generateGenome(ArrayList<Integer> inputNodes, ArrayList<Integer> outputNodes) {
		return new BasicGenome(inputNodes, outputNodes);
	}

	@Override
	public void setName(BasicGenome element, String name) {
		element.setName(name);
	}
	
}
